IF OBJECT_ID('vds_device_information') IS NOT NULL
	BEGIN
		IF OBJECT_ID('vds_device_information_insert_trigger') IS NOT NULL
			DROP TRIGGER vds_device_information_insert_trigger;
		IF OBJECT_ID('vds_device_information_delete_trigger') IS NOT NULL
			DROP TRIGGER vds_device_information_delete_trigger;
		DROP TABLE vds_device_information;
	END;
GO

CREATE TRIGGER vds_device_information_insert_trigger
ON vds_device_information
INSTEAD OF INSERT
AS
BEGIN
	INSERT INTO vds_device_information SELECT _model, _imei, _imeiSv, _serialNo, _wlanMac, _osVersion FROM inserted;
	INSERT INTO vds_device_status (_id, _expiredTime) VALUES (@@IDENTITY, GETDATE());
END;
GO